{  26 February 2011. Individual Olympiad. Problem set: http://neerc.ifmo.ru/school/io/archive/20110226/problems-20110226-individual.pdf
	Problem B
	Points: 100
}
uses sysutils;
var i,n,j,x1,y1,x2,y2,m,k:longint; res:INT64; f:boolean; a:array[0..1001,0..1001] of integer;
function check(i,j,k:longint):boolean;
begin
if (a[i][j]<>0) or ((a[i-1][j-1]<>0) and (a[i-1][j-1]<>k)) or ((a[i-1][j]<>0) and (a[i-1][j]<>k)) or ((a[i-1][j+1]<>0) and (a[i-1][j+1]<>k)) or ((a[i+1][j-1]<>0) and (a[i+1][j-1]<>k)) or ((a[i+1][j]<>0) and (a[i+1][j]<>k)) or ((a[i+1][j+1]<>0) and (a[i+1][j+1]<>k)) or ((a[i][j-1]<>0) and (a[i][j-1]<>k)) or ((a[i][j+1]<>0) and (a[i][j+1]<>k)) then result:=true else result:=false;
end;
begin
reset(input,'battleship.in');
rewrite(output,'battleship.out');
fillchar(a,sizeof(a),0);
readln(n,m,k);
f:=false;
for i:=1 to k do begin
  readln(x1,y1,x2,y2);
  if x1=x2 then begin
    for j:=y1 to y2 do
      if check(x1,j,i)=true then f:=true else a[x1][j]:=i;
  end else begin
    for j:=x1 to x2 do
      if check(j,y1,i)=true then f:=true else a[j][y1]:=i;
    end;
end;
if f then writeln('INCORRECT') else begin
res:=0;
for i:=1 to n do begin
  for j:=1 to m do begin
    if (a[i-1][j-1]<>0) OR (a[i-1][j]<>0) or (a[i-1][j+1]<>0) or (a[i+1][j-1]<>0) OR (a[i+1][j]<>0) or (a[i+1][j+1]<>0) or (a[i][j-1]<>0) or (a[i][j+1]<>0) or (a[i][j]<>0) then else inc(res);
  end;
end;
writeln(res);
end;
end.
